// 志愿活动数据请求
import qs from 'qs'
import { request } from './request'

// 获取活动信息
export function getActivity () {
  return request({
    url: '/api/list/activity'
  })
}

// 根据活动 id 获取数据
export function getActivityById (activity_id) {
  return request({
    url: '/api/list/activity/' + activity_id
  })
}

// 发布活动
export function addActivity (activity) {
  return request({
    url: '/admin/activity/publish',
    method: 'post',
    headers: {'Content-Type': 'multipart/form-data'},
    data: activity
  })
}

// 修改活动
export function updateActivity (activity) {
  return request({
    url: '/admin/activity/update',
    method: 'post',
    headers: {'Content-Type': 'multipart/form-data'},
    data: activity
  })
}

// 更改活动状态为已完成
export function updateState (activity_id) {
  return request({
    url: '/admin/activity/update/' + activity_id,
    method: 'post'
  })
}

// 取消活动
export function cancelActivity (cancel) {
  return request({
    url: '/admin/activity/cancel',
    method: 'post',
    headers:{'Content-Type':'application/x-www-form-urlencoded'},
    data: qs.stringify(cancel)
  })
}

// 删除活动
export function deleteActivity (activity_id) {
  return request({
    url: '/admin/activity/delete/' + activity_id,
    method: 'post'
  })
}